<template>
  <div class="myinsuretwo">
      <div class="myinsuretwo_center">
         <div class="title">
            <div class="titlecontent">
               <div class="titlec">
                    <p class="titleitem" @click="titlelist(1);">
                        <span>{{xian_state}}</span>
                        <img v-bind:class=" statearr==1 ? {active: isActive}:{active:false}" src="~@/assets/img/list_xia.png" alt="">
                    </p>
                    <p class="titleitem" @click="titlelist(2);">
                        <span>{{appliy_state}}</span>
                        <img v-bind:class=" statearr==2 ? {active: isActive}:{active:false}" src="~@/assets/img/list_xia.png" alt="">
                    </p>
                    <p class="titleitem" @click="titlelist(3);">
                        <span>{{policy_state}}</span>
                        <img v-bind:class=" statearr==3 ? {active: isActive}:{active:false}" src="~@/assets/img/list_xia.png" alt="">
                    </p>
               </div>
               <!-- 下拉列表 -->
               <div class="slide" v-for="item in muselist" v-show="statearr==item.id" v-bind:key="item.id">
                   <p v-for="item1 in item.list" @click="itemtype(item1.sid)" v-bind:key="item1.sid">
                       {{item1.name}}
                    </p>
               </div>
            </div>
         </div>
         <!-- 车险列表 -->
        <div class="listcontent"  >
            <!-- <div  v-show="chexianLists_null" class="null">
                <div class="myInsure_container" >
                    <div class="myInsure_all">
                        <div style="text-align: center;margin: 0 auto;">
                            <img style="margin-bottom: 30px; width:95px; height:95px;" src="~@/assets/img/myInsure_null.png" >
                            <p style="margin-bottom: 65px;color:rgba(153, 153, 153, 1); font-size: 16px;">未查询到您名下的保单信息</p>
                            <p style="margin-bottom: 21px;color: rgba(51, 51, 51, 1); font-size: 16px;" v-if="kunming_hidden">查询其他保单请点击</p>
                            <div class="myInsure_btn" v-if="kunming_hidden" ng-click="myInsure_null()">
                                <span>立即查询</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div> -->
            <div v-show="chexianLists_div" style="overflow:auto">
                <div  v-for="Num in cxlist" style="overflow:auto">
                    <div class="listitem lactive"  v-for="num in Num.policys"  v-show='num.show'>
                        <div @click="warrantyDetails(num,'c')">
                            <div class="itemtitle" >
                                <div class="itemtitle_div1">
                                    <span class="title1">{{riskcode1}}</span>
                                    <div :class="{stateactive1:num.number=='保障中',stateactive2:num.number=='已过期',stateactive3:num.number=='未起保'}" class="mystate">
                                        <!-- <span class="state1">{{num.number}}</span> -->
                                    </div>
                                </div>
                            </div>
                            <div class="listitemcontent ">
                                    <p>
                                        <span>投保车辆</span>
                                        <span>{{Num.licenseNo}}</span>
                                    </p>
                                     <p >
                                    <!-- <p v-if="appliy_stateid==2||appliy_stateid==1"> -->
                                        <span>投保人</span>
                                        <span>{{num.appliname}}</span>
                                    </p>
                                     <p >
                                    <!-- <p v-if="appliy_stateid==3||appliy_stateid==1"> -->
                                        <span>被保人</span>
                                        <span>{{num.insname}}</span>
                                    </p>
                                    <p>
                                        <span>保障期限</span>
                                        <span v-if="num.startDate1 && num.endDate1" style="padding: 0 20px 0 0; display: block;  word-wrap: break-word; text-align: right; width: 70%; float: right;">{{(num.startDate1).replace(/-/g,"/")}}&nbsp-&nbsp{{(num.endDate1).replace(/-/g,"/")}}</span>
                                    </p>
                            </div>
                        </div>
                    </div>
                </div>
             </div>
        </div>
        <!-- 非车险列表 -->
        <div class="listcontent2">
             <!-- <div  v-show="chexianLists_null_feichexian" class="null">
                <div class="myInsure_container" >
                    <div class="myInsure_all">
                        <div style="text-align: center;margin: 0 auto;">
                            <img style="margin-bottom: 30px; width:95px; height:95px;" src="~@/assets/img/myInsure_null.png" >
                            <p style="margin-bottom: 65px;color:rgba(153, 153, 153, 1); font-size: 16px;">未查询到您名下的保单信息</p>
                            <p style="margin-bottom: 21px;color: rgba(51, 51, 51, 1); font-size: 16px;" v-if="kunming_hidden">查询其他保单请点击</p>
                            <div class="myInsure_btn" v-if="kunming_hidden" ng-click="myInsure_null()">
                                <span>立即查询</span>
                            </div>
                        </div>
                    </div>
                </div>
             </div> -->
             <div v-show="chexianLists_div" style="overflow:auto"> 
                <div   v-for="Num in fxlist" style="overflow:auto">
                    <div class="listitem lactive1" v-for="num in Num.policys" v-show='num.show'>
                        <div @click="warrantyDetails(num,'f',Num.riskname)">
                            <div class="itemtitle" >
                                <div class="itemtitle_div1">
                                    <span  class="title1">{{num.riskname}}</span>
                                    <div :class="{stateactive1:num.number=='保障中',stateactive2:num.number=='已过期',stateactive3:num.number=='未起保'}" class="mystate">
                                        <!-- <span class="state1">{{num.number}}</span> -->
                                    </div>
                                </div>
                            </div>
                            <div class="listitemcontent">
                                <!-- <p v-if="appliy_stateid==2||appliy_stateid==1"> -->
                                <p >
                                    <span>投保人</span>
                                    <span>{{num.appliname}}</span>
                                </p>
                                 <p >
                                <!-- <p v-if="appliy_stateid==3||appliy_stateid==1"> -->
                                    <span>被保人</span>
                                    <span>{{num.insname}}</span>
                                </p>
                                <p>
                                    <span>保障期限</span>
                                    <span v-if="num.startDate1 && num.endDate1" style="padding: 0 20px 0 0; display: block;  word-wrap: break-word; text-align: right; width: 70%; float: right;">{{(num.startDate1).replace(/-/g,"/")}}&nbsp-&nbsp{{(num.endDate1).replace(/-/g,"/")}}</span>
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- 为查询到您名下的保单信息 v-if="Lists_null"-->
        <!-- <van-loading type="spinner" v-show="loadflag" color="#1989fa"  style="opacity:0; margin:1260px 0 560px 0;text-align: center;" /> -->
        <div  v-if="Lists_null" class="null">
            <div class="myInsure_container" >
                <div class="myInsure_all">
                    <div style="text-align: center;margin: 0 auto;">
                        <img style="margin-bottom: 30px; width:95px; height:95px;" src="~@/assets/img/myInsure_null.png" >
                        <p style="margin-bottom: 65px;color:rgba(153, 153, 153, 1); font-size: 16px;">未查询到您名下的保单信息</p>
                        <p style="margin-bottom: 21px;color: rgba(51, 51, 51, 1); font-size: 16px;" v-if="kunming_hidden">查询其他保单请点击</p>
                        <div class="myInsure_btn" v-if="kunming_hidden" @click="myInsure_null()">
                            <span>立即查询</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
      </div>
  </div>
</template>
<script lang="ts">
import '../../style/reservaIndex_index.css';
import 'vant/lib/toast/style';
import 'vant/lib/dialog/style';
import { Toast } from 'vant';
import { Component, Vue, Prop } from 'vue-property-decorator';
import { cloudApi } from '@/api/indexApi';
import Header from '@/components/Header.vue';
import {  Alert } from '@/utils';
import { Dialog  } from 'vant';
import func from 'vue-temp/vue-editor-bridge';
import Vue from 'vue';
import { Loading } from 'vant';
Vue.use(Loading);
Vue.use(Dialog);
Component.registerHooks(['beforeRouteUpdate', 'beforeRouteLeave', 'beforeRouteLeave']);
@Component({
  components: { Header },
})
export default  class Myinsuretwo extends Vue{
    statearr: any=[]
    sid: any=''
    xian_state: string=''
    appliy_state: string=''
    policy_state: string=''
    muselist: any=[]
    InsufoLists_AllValue:any=[]
    isActive: any=false
    x: any=''
    riskname: any=''
    policy_state_bz: any='true' //保障中
    policy_state_yg: any='true' //已过期
    flag: any=''
    name:any=''//当前用户的名字
    platenumbers:any=''//车牌号 数组
    appliname : any='true'//投保人
    insname : any='false' //被保人
    cxlist:any=''//车险
    fxlist:any=''//非车险
    cxlist1:any=''
    fxlist1:any=''
    policys:any=''
    riskcode1:any=''//0507-交强险 else商业险
    xian_state : any="险种"
    xian_stateid:any='1'
    appliy_state : any="身份"
    appliy_stateid:any='1'
    policy_state : any="保单状态"
    policy_stateid:any='2'
    cx_shengxiao_count : any=0//车险有效中
    cx_shixiao_count : any=0//车险失效
    fc_shengxiao_count :any= 0//非车险生效中
    fc_shixiao_count : any=0//非车险失效
    InsufoLists_AllValue:any=[]//车险 cxlist
    AutoInsufo_ListsValue : any=[]//非车险 fxlist
    fc_length:any=''//非车险的长度
    // 盒子
    chexianLists :any='true'//车险
    feichexianLists : any='true'//非车险
    chexianLists_div : any='true'  //车险div
    chexianLists_null :any='false' //车险长度是否0
    feichexianLists_div : any='true'//非车险div
    chexianLists_null_feichexian : any='false'//非车险长度是否0
    Lists_null:any='false'
    kunming_hidden:any='true' //立即查询
    statearr:any=0//当前列表状态muselist id
    sid:any=0 //list sid
    cx_length: any=''
    openId:any=''
    aa:any=''

    timeDifference1: any=''
    timeDifference: any=''
    isapp: any=''
    app_true: any= false;
    heilongjiang_hidden: any=false;
    flagkhj: any= '';
    customerPhone: any=''
    userId: any=''
    appkey: any=''
    type_card: any=''
    id_card: any=''
    party_id: any=''
    lever: any=''
    myInsure_id: any=''
    informationId: any=''
    appid: any=''
    code: any=''
    uid: any=''
    unionId: any=''
    appopid: any=''
     //点击我的保险
    ifSuperThree: any = true //确定我的名片加号是否显示
    Referee: any = false //推荐人标识
    newEnergy: any = false //新能源汽车绿色车牌
    normalCar: any = true //普通汽车蓝色车牌

    emailTrue: any = false;
    myInfo: any={emailVal:'请输入邮箱信息'}
    gou_xcx: any = true;
    BFDReady: any = false
    loadflag: any = false
   data(){
       return{ 
            muselist:[
                {id:1,list:[{sid:1,name:'全部'},{sid:2,name:'车险'},{sid:3,name:'非车险'}]},
                {id:2,list:[{sid:1,name:'全部'},{sid:2,name:'投保人'},{sid:3,name:'被保人'}]},
                {id:3,list:[{sid:1,name:'全部'},{sid:2,name:'保障中'},{sid:3,name:'已过期'},{sid:4,name:'未起保'}]}
                ]
       }
    }
    created(){
        this.Lists_null=false
        this.myInsureClick()
    }

    mounted() {
    //         Toast.loading({
    //   duration: 0,
    //   message: '加载中...',
    //   forbidClick: true,
    // });
        if (window.history && window.history.pushState) {
      // 向历史记录中插入了当前页
      history.pushState(null, null, document.URL);
      window.addEventListener('popstate', this.goBack, false);
    }
   }
    destroyed () {
    window.removeEventListener('popstate', this.goBack, false);
  }
  
  goBack () {
    // window.history.back();
    if((window as any).wx.miniProgram){
      (window as any).wx.miniProgram.navigateBack({
        delta: history.length
      })
    }
  }
    //下拉框
  itemtype(num: any){
       this.sid=num; 
       if(this.statearr==1){//险种 车险 非车险
            this.xian_state=this.muselist[0].list[this.sid-1].name
            this.xian_stateid=num
            if(this.muselist[0].list[this.sid-1].sid==2){//车险
                this.chexianLists= true;
                this.feichexianLists=false;
            }else if(this.muselist[0].list[this.sid-1].sid==3){//非车险
                this.feichexianLists=true;
                this.chexianLists= false;
            }else{//全部
                this.feichexianLists=true;
                this.chexianLists= true;
            }
       }else if(this.statearr==2){//身份 投保人 被投保人
            this.appliy_state=this.muselist[1].list[this.sid-1].name
            this.appliy_stateid=num
            this.insname = true;
       }else if(this.statearr==3){//保单状态 保障中 已过期
            this.policy_state=this.muselist[2].list[this.sid-1].name
            this.policy_stateid=num
        }
        this.muselistt()
        this.statearr=0
  }
 
  muselistt(){
    if(this.appliy_stateid==2){
        this.fxlist1=[]
        this.cxlist1=[]
        for (var i in this.fxlist){
            for (var q in this.fxlist[i].policys){
                if(this.fxlist[i].policys[q].appliname==this.name){
                    // this.fxlist1.push(this.fxlist[i].policys[q])
                    this.fxlist[i].policys[q].show=true
                }else{
                    this.fxlist[i].policys[q].show=false
                }
                
            }
        }
        for (var i in this.cxlist){
            for (var q in this.cxlist[i].policys){
                if(this.cxlist[i].policys[q].appliname==this.name){
                    // this.cxlist1.push(this.cxlist[i].policys[q])
                    this.cxlist[i].policys[q].show=true
                }else{
                    this.cxlist[i].policys[q].show=false
                }
                
            }
        }
           
    }else if(this.appliy_stateid==3){
        this.fxlist1=[]
         this.cxlist1=[]
        for (var i in this.cxlist){
            for (var q in this.cxlist[i].policys){
                if(this.cxlist[i].policys[q].insname==this.name){
                    // this.cxlist1.push(this.cxlist[i].policys[q])
                    this.cxlist[i].policys[q].show=true
                }else{
                    this.cxlist[i].policys[q].show=false
                }
                
            }
        }
        for (var i in this.fxlist){
            for (var q in this.fxlist[i].policys){
                if(this.fxlist[i].policys[q].insname==this.name){
                    // this.fxlist1.push(this.fxlist[i].policys[q])
                    this.fxlist[i].policys[q].show=true
                }else{
                    this.fxlist[i].policys[q].show=false
                }
                
            }
        }
           
    }else{
        this.fxlist1=[]
        this.cxlist1=[]
        for (var i in this.fxlist){
            for (var q in this.fxlist[i].policys){
                    // this.fxlist1.push(this.fxlist[i].policys[q])
                    this.fxlist[i].policys[q].show=true
            }
        }
         for (var i in this.cxlist){
            for (var q in this.cxlist[i].policys){
                    // this.cxlist1.push(this.cxlist[i].policys[q])
                    this.cxlist[i].policys[q].show=true
            }
        }
           
    }

    if(this.policy_stateid==2){
       var fxlist2=[];
       var cxlist2=[];
        for (var i in this.fxlist){
            for (var q in this.fxlist[i].policys){
                if(this.fxlist[i].policys[q].number == '保障中'&&this.fxlist[i].policys[q].show==true){
                    this.fxlist[i].policys[q].show=true
                }else{
                    this.fxlist[i].policys[q].show=false
                }
                
            }
        }
        // this.fxlist1=fxlist2
        for (var i in this.cxlist){
            for (var q in this.cxlist[i].policys){
                if(this.cxlist[i].policys[q].number == '保障中'&&this.cxlist[i].policys[q].show==true){
                     this.cxlist[i].policys[q].show=true
                }else{
                    this.cxlist[i].policys[q].show=false
                }
                
            }
        }
        // this.cxlist1=cxlist2
           
    }else if(this.policy_stateid==3){
       var fxlist2=[];
       var cxlist2=[];
        for (var i in this.fxlist){
            for (var q in this.fxlist[i].policys){
                if(this.fxlist[i].policys[q].number == '已过期'&&this.fxlist[i].policys[q].show==true){
                    this.fxlist[i].policys[q].show=true
                }else{
                    this.fxlist[i].policys[q].show=false
                }
                
            }
        }
        // this.fxlist1=fxlist2
        for (var i in this.cxlist){
            for (var q in this.cxlist[i].policys){
                if(this.cxlist[i].policys[q].number == '已过期'&&this.cxlist[i].policys[q].show==true){
                     this.cxlist[i].policys[q].show=true
                }else{
                    this.cxlist[i].policys[q].show=false
                }
                
            }
        }
        // this.cxlist1=cxlist2
           
    }else if(this.policy_stateid==4){
       var fxlist2=[];
       var cxlist2=[];
        for (var i in this.fxlist){
            for (var q in this.fxlist[i].policys){
                if(this.fxlist[i].policys[q].number == '未起保'&&this.fxlist[i].policys[q].show==true){
                    this.fxlist[i].policys[q].show=true
                }else{
                    this.fxlist[i].policys[q].show=false
                }
                
            }
        }
        // this.fxlist1=fxlist2
        for (var i in this.cxlist){
            for (var q in this.cxlist[i].policys){
                if(this.cxlist[i].policys[q].number == '未起保'&&this.cxlist[i].policys[q].show==true){
                     this.cxlist[i].policys[q].show=true
                }else{
                    this.cxlist[i].policys[q].show=false
                }
                
            }
        }
        // this.cxlist1=cxlist2
           
    } else{
        for (var i in this.fxlist){
            for (var q in this.fxlist[i].policys){
                //   this.fxlist[i].policys[q].show=true
                
            }
        }
        for (var i in this.cxlist){
            for (var q in this.cxlist[i].policys){
                //    this.cxlist[i].policys[q].show=true
            }
        }
        // this.cxlist1=cxlist2
           
    }

    this.chexianLists_null_feichexian=true
    if(this.xian_stateid==2){
         for (var i in this.fxlist){
            for (var q in this.fxlist[i].policys){
                this.fxlist[i].policys[q].show=false
            }
        }
    }
    for (var i in this.fxlist){
        for (var q in this.fxlist[i].policys){
            if(this.fxlist[i].policys[q].show==true){
                this.chexianLists_null_feichexian=false
            }
        }
    }
    
   
    this.chexianLists_null=true
    if(this.xian_stateid==3){
        for (var i in this.cxlist){
            for (var q in this.cxlist[i].policys){
                this.cxlist[i].policys[q].show=false
            }
        }
    }
    for (var i in this.cxlist){
        for (var q in this.cxlist[i].policys){
             if(this.cxlist[i].policys[q].show==true){
                     this.chexianLists_null=false
            }
        }
    }
    
    if(this.chexianLists_null_feichexian==true&&this.chexianLists_null==true){
        this.Lists_null=true
        if (this.policy_state=="保单状态") {
           this.policy_stateid='1'
           this.policy_state='全部'
           this.muselistt()
        }
    }else{
        this.Lists_null=false
    }
    
  }
  titlelist(num: any){
      if(this.statearr==num){
          this.statearr=0
          this.isActive=false
      }else{
         this.statearr=num;
         this.isActive=true
      }
      
  }
    //我的保险、保单明细
  warrantyDetails(x:any,y:any,riskname:any=null){
    //x是实参
    //y用来判断车险/非车险用于后面的埋点
    //riskname 保险名称
    var _this=this
    console.log("保单详情",x)
    localStorage.setItem('x',JSON.stringify(x))//本地存储
    localStorage.setItem('y',JSON.stringify(y))//本地存储
    localStorage.setItem('riskname',JSON.stringify(riskname))//本地存储
    var reference:any = {
        openid:_this.openId,
        userid:_this.userId,
        code:_this.code,
        id_card:_this.id_card
    }
    localStorage.setItem('reference',JSON.stringify(reference))
    console.log("reference",reference)
    if(_this.lever==1){
            // _this.mainModal.hide();
            Dialog.alert({ title: '温馨提示', message: '您当前没有权限查看保单详情，请前往我的-个人信息-个人名片-信息维护中补充认证投保信息' });
            return;
    }else{
        _this.$router.push({
            path:'AppPolicyDetails'
        })
    }
    
  }
  BuryingPoint(x:any, y:any) {
        this.BFDReady = false; //埋点是否初始化完毕标识
        window["_BFD"] = window["_BFD"] || {};
        _BFD.USER_INFO = {
            "cid": "Czgrs_cxgsh", //客户标识，实施人员提供
            "appkey": this.appkey, //应用标识，实施人员提供
            "pv_type": "0", //页面埋点方式，0 为自动发送，1 为手动调用
            "pos": true, //是否启用鼠标点击事件，值为 true/false
            "link": true, //是否启用链接点击事件，值为 true/false
            "title": "", //当前页面标题，若此处不回传默认获取 document.title
            "openID": y || '', //站点在微信加载时，需回传 openID，否则不用做处理
            "phone_number": "", //手机号码，未登录时回传空字符串
            "uid": x || '' //用户 id，未登录时回传空字符串
        };
        _BFD.script = document.createElement("script");
        _BFD.script.async = true;
        _BFD.script.charset = "utf-8";
        // _BFD.script.src=('http://119.3.79.235:9999/jsapi/zgrsweb.js'); // js 代码路径，由实施人员提供
        _BFD.script.src = ('https://detector.chinalife-p.com.cn/jsapi/zgrsweb.new.js'); // js 代码路径，由实施人员提供
        document.getElementsByTagName("head")[0].appendChild(_BFD.script);
  };
  //获取保单信息列表
  myInsureList(){
     var _this = this;
     if (_this.flagkhj == "khj") { //客户节
        var data:any = {
            user_id: _this.userId,
            openid: _this.openId,
            name: _this.name,
            idtype: _this.type_card,
            idcard: _this.id_card,
            partyid: _this.party_id,
            authority: _this.lever,
            code: _this.code,
            customerPhone: _this.customerPhone,
            unionid: _this.unionId
        }
     }else{
         var data:any = {
            user_id: _this.userId,
            openid: _this.openId,
            name: _this.name,
            idtype: _this.type_card,
            idcard: _this.id_card,
            partyid: _this.party_id,
            authority: _this.lever,
            code: _this.code
        }
     }
     var data1:any = AESEncode(data);
    cloudApi
      .getMyPolicyListsInf({
          result: data1
      })
      .then(function(res) {
         _this.loadflag=false;
        //   Toast.clear();
        _this.getCardDetail(); //查询用户邮箱信息
        var data:any = JSON.parse(decodeURIComponent(atob(res.data.result)));
        console.log(data)
        if (data.result == 'notSame') {
            //页面埋点报错
            alert('openid和userid不一致');
            return;
        }
        if (data.result == 'forSecure') {
            //页面埋点报错
            alert('code已失效');
            return;
        }
        if (data.result == "jsonwrong") {
            // 页面报错埋点
            alert("输入的三要素和之前从平台中取的不一致");
            return;
        }
        //alert("获取保单信息列表"+JSON.stringify(data));
        _this.cxlist = data.result.list1;//车险
        _this.fxlist = data.result.list2;//非车险
        _this.cx_length = _this.cxlist.length//车险的长度
        //车险循环
        _this.cxlist.forEach(function (x:any) {
            x.policys.forEach(function (item:any) {
                if (item.number == '失效') {
                     item.number = '已过期';
                 _this.cx_shixiao_count++;
                } else if (item.number == '有效'){
                    item.number = '保障中';
                    _this.cx_shengxiao_count++;
                }
                if (item.riskcode == '0507') {
                    _this.riskcode1 = '交强险'
                } else {
                    _this.riskcode1 = '商业险'
                }
                item.startDate1 = item.startDate.split('+')[0];
                item.endDate1 = item.endDate.split('+')[0];
            })
        });
        _this.InsufoLists_AllValue = _this.cxlist //车险
        var fclist:any = [] //非车险
        data.result.list2.forEach(function (item:any) {
            fclist = fclist.concat(item.policys)
        });
        //非车险循环
        fclist.forEach(function (item) {
                 if (item.number == '失效') {
                    item.number = "已过期";
                     _this.fc_shixiao_count++;
                     item.fc_shixiao_count = 1;
                     item.fc_shengxiao_count = 0;
                 } else if (item.number == '有效'){
                     item.number = "保障中";
                     _this.fc_shengxiao_count++;
                     item.fc_shengxiao_count = 1;
                    item.fc_shixiao_count = 0;
                 }
            item.startDate1 = item.startDate.split('+')[0];
            item.endDate1 = item.endDate.split('+')[0];
        });
        _this.AutoInsufo_ListsValue = fclist; //非车险
        _this.fc_length = fclist.length;
        // _this.initSwitch($scope.cx_length, $scope.fc_length);
        console.log("车险生效", _this.cx_shengxiao_count, '车险失效', _this.cx_shixiao_count, '非车生效', _this.fc_shengxiao_count, '非车失效', _this.fc_shixiao_count)
        _this.muselistt()
      })
      .catch(err => {
            // $scope.mainModal.hide();
            // 页面报错埋点
            //  Toast.clear();
            sensors.track('kf_PageError', {
                page_title: document.title,
                page_url: window.location.href,
                error_reason: '暂时不能为您服务，请拨打95519或4008695519'
            });
            Dialog.alert({ title: '温馨提示', message: '暂时不能为您服务，请拨打95519或4008695519！' }); 
       });
  }     
  //立即查询            
  myInsure_null() {
      var _this = this
    //测试链接
    if (_this.app_true) { //app进入
        var demo = "https://wechat.chinalife-p.com.cn/wechatpageview/warranty_index.html?userId=" + _this.userId;
        // var demo = "https://wechattest.chinalife-p.com.cn/wechatpageview/warranty_index.html?userId=" + _this.userId;
    } else { //微信进入
        // var demo = "https://wechat.chinalife-p.com.cn/wechatpageview/warranty_index.html?appid=" + _this.appid + "&code=" + _this.code + "&state=" + _this.uid;
        //生产
        var demo = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx5668b394c2053c79&redirect_uri=https%3a%2f%2fwechat.chinalife-p.com.cn%2fwechatpageview%2fwarranty_index.html%3fappid%3dwx5668b394c2053c79&response_type=code&aaa=aa&scope=snsapi_base&state=e52b56e8423da66c17ad469b14778eb733e91e65442075c6e4739460d6eccaedopenidoWcBG426UritXl5FqGtlP3rf8a0E#wechat_redirect'
        //var demo = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxb1b70bf91a06f3e5&redirect_uri=https%3a%2f%2fwechattest.chinalife-p.com.cn%2fwechatpageview%2fwarranty_index.html%3fappid%3dwxb1b70bf91a06f3e5&response_type=code&aaa=aa&scope=snsapi_base&state=82d5fa5048fae3251c0e5beadf2a6e7616c20c62cebde8e7a3a91453a1f9f69aopenidoWcBG4_5kZ0fv4IGtgDUToTPLsmU#wechat_redirect'
        // var demo = "https://wechattest.chinalife-p.com.cn/wechatpageview/warranty_index.html?appid=" + _this.appid + "&code=" + _this.code + "&state=" + _this.uid;
    }
    // var demo = "http://wechattest.chinalife-p.com.cn/wechatpageview/warranty_index.html?appid="+$scope.appid+"&code="+$scope.code+"&state="+$scope.uid;
    //生产链接
        window.location.href = demo;
  }
  myInsureClick(){
      var _this=this
      console.log("myInsureClick")
      _this.timeDifference = new Date().getTime(); //页面初始时间
      console.log(11, _this.timeDifference)
    //   $scope.mainModal.show();
    
     var address = location.href;
     if(this.$route.query.unionId){
         _this.unionId=this.$route.query.unionId
         _this.appopid=this.$route.query.appopid
     }else{
        _this.unionId=address.split("?")[1].split("unionId=")[1].split("&")[0]
        _this.appopid=address.split("?")[1].split("appopid=")[1].split("&")[0]
     } 
     // var address:any = 'https://wechattest.chinalife-p.com.cn/wechatpageview/myInsure_index.html?appid=wxb1b70bf91a06f3e5&code=071cEW000tFxgL1tS4000r6EE33cEW0D&state=appeal'
    // var address = 'http://wechattest.chinalife-p.com.cn/wechatpageview/myInsure_index.html?userId=545'
     
      _this.getcard()
     _this.getEnv();
  }
  getEnv() {
      var _this=this
        console.log(_this.app_true);
        if (_this.app_true) {
            _this.gou_xcx = false;
        } else {
            if (-1 == navigator.userAgent.toLowerCase().indexOf("micromessenger")) {
                _this.gou_xcx = false;
                console.log("在其他浏览器中");
            } else {
                wx.miniProgram.getEnv((res:any) => {
                    console.log(res);
                    if (res.miniprogram) {
                        _this.gou_xcx = true;
                        console.log("在小程序中");
                    } else {
                        _this.gou_xcx = false;
                        console.log("在微信中");
                    }
                })
            }
        }
    }
  //通过userid查询用户信息2
  queryUserInfoById(){
  var _this = this
     //aes加密
    var data:any = AESEncode({
        user_id: _this.userId
    })
    cloudApi
        .queryUserInfoByIdURL({
            result: data
        })
        .then(function(res) {
            // $scope.mainModal.hide();
            var data:any = JSON.parse(decodeURIComponent(atob(res.data.result)));
            console.log(data);
            _this.name = data.result.user_name;
            _this.type_card = data.result.user_card_type;
            _this.id_card = data.result.user_card_no;
            _this.party_id = data.result.user_ecif_id;
            _this.lever = '2';
            _this.myInsure_id = data.result.user_id;
            _this.informationId = data.result.id;
        })
        .catch(err => {
            // $scope.mainModal.hide();
            // 页面报错埋点
            sensors.track('kf_PageError', {
                page_title: document.title,
                page_url: window.location.href,
                error_reason: '暂时不能为您服务，请拨打95519或4008695519'
            });
            Dialog.alert({ title: '温馨提示', message: '暂时不能为您服务，请拨打95519或4008695519！' }); 
        });
  }
  GetRequest(urls: any) {
    var url = urls.split("?")[1]; //获取url中"?"符后的字串
    var z:any = new Object();
    if (url != undefined) {
        var x = url.split("&");
        for (var i = 0; i < x.length; i++) {
            z[x[i].split("=")[0]] = decodeURIComponent(x[i].split("=")[1]);
        }
    }
    return z;
  }
  GetRequest2(arr: any, str: any){
    var z:any = new Object();
    var value = str.split('_')
    arr.map(function (key: any, index: any) {
        z[key] = value[index].substr(key.length);
    })
    return z;
  }
  // 获取unionid1
  getUnionId(){
      var _this=this
    if (_this.uid != 'appeal' && _this.uid != ''){
        if (window.location.href.indexOf('openid') != -1){
            _this.unionId = window.location.href.split("state=")[1].split("openid")[0]
        }else{
            var data:any = AESEncode({
                id: _this.uid
            })
            cloudApi
                .getThreeidByIdURL({
                    result: data
                })
                .then(function(res){
                    console.log(res)
                        var data:any = AESDecode(res.data.result)
                        console.log(data)
                        _this.unionId = data.unionid
                })
                .catch(err => {
                    console.log(err)
                });
        }
    }
  }
  // getUnionIdAndOpenId(){
  //   var _this = this;
  //   cloudApi
  //     .getUnionIdAndOpenId({
  //       appid: _this.appid,
  //       code: _this.code,
  //     })
  //     .then(function(res: any) {
  //       if (res.data) {
  //         if(res.data.unionId){
  //           _this.unionId = res.data.unionId;
  //           sessionStorage.setItem('unionId', res.data.unionId||'');
  //           _this.openId = res.data.openId;
  //           _this.getcard();
  //           sessionStorage.setItem('openId', res.data.openId||'');
  //         }
  //       }
  //     });
  // }
  //名片初始化1
  getcard(){
    var _this = this
    var data:any = AESEncode({
        openid: '',
        unionid: _this.unionId,
        appopenid:_this.appopid
    })
     console.log("unionId——zwh",_this.unionId)
    console.log(data)
    cloudApi
      .getMyBussinessCard({
          result:data
      })
      .then(function(res) {
        var data:any = AESDecode(res.data.result)
        console.log("getMyBussinessCard解密",data)
        if (data.result.length == 0) {
            // _this.$router.push('view/myInformation/myInformation_customer.html')
             _this.$router.push({
              path: 'checkPhoneInfo',
              query: {
                unionId: '',
                openId: '',
                route: JSON.stringify({
                  path: 'Myinsure',
                  query: {
                    unionId:_this.unionId,
                    appopid:_this.appopid
                  },
                })
              },
            });
            // $scope.mainInfo.pushPage("view/myInformation/myInformation_customer.html"); //如果没有数据跳转到输入手机号页面
            return;
        } else {
            console.log(data.result);
            var mycard = data.result[0];
            _this.userId = mycard.user_id;
            _this.name = mycard.name;
            _this.type_card = mycard.type_card;
            _this.id_card = mycard.id_card;
            _this.party_id = mycard.party_id;
            _this.lever = mycard.lever;
            _this.myInsure_id = mycard.id;
            _this.informationId = mycard.id;
            // $scope.myInsureList();
            _this.myInsureList() 
            // $scope.mainInfo.pushPage("view/myInsure/myInsure.html");
            return;
        }
      })
      .catch(err => {
            // $scope.mainModal.hide();
            // // 页面报错埋点
            sensors.track('kf_PageError', {
                page_title: document.title,
                page_url: window.location.href,
                error_reason: '暂时不能为您服务，请拨打95519或4008695519'
            });
      });
  }
  //查询用户邮箱信息
  // $scope.myInfo.emailVal = "请输入邮箱信息"
  getCardDetail() {
    // $scope.mainModal.show();
    var _this = this
    //aes加密
    var data1:any = AESEncode({
        id: _this.informationId,
        idCard: _this.id_card,
        partyId: _this.party_id,
        typeCard: _this.type_card
    });
    console.log("aes加密", data1)
    cloudApi
        .getMyBussinessCardDetailURL({
            result: data1
        })
        .then(function(res){
            // $scope.mainModal.hide();
            // 页面加载埋点
            _this.timeDifference1 = new Date().getTime()
            var time = (_this.timeDifference1 - _this.timeDifference) / 1000;
            sensors.track('kf_PageLoading', {
                page_title: document.title,
                page_url: window.location.href,
                loading_duration: time,
                is_loading_success: '加载成功'
            })
            //aes解密
        var data:any = AESDecode(res.data.result);
        console.log("aes解密", data);
        if (data == "解密出错") {
            _this.myInfo.emailVal = '';
        } else {
            _this.myInfo.emailVal = data.result.email;
        }
        console.log("用户绑定邮箱信息", _this.myInfo.emailVal);
        _this.emailTrue = true;
        var email:any = {
            myInfo:_this.myInfo,
            emailTrue:_this.emailTrue
        }
        localStorage.setItem('email',JSON.stringify(email))

        })
        .catch(err => {
             // 页面加载埋点
            _this.timeDifference1 = new Date().getTime()
            var time = (_this.timeDifference1 - _this.timeDifference) / 1000;
            sensors.track('kf_PageLoading', {
                page_title: document.title,
                page_url: window.location.href,
                loading_duration: time,
                is_loading_success: '加载失败'
            })
            // 页面报错埋点
            sensors.track('kf_PageError', {
                page_title: document.title,
                page_url: window.location.href,
                error_reason: err
            });
            // $scope.mainModal.hide();
            _this.emailTrue = true;
            console.log("查询邮箱失败");
          });
  }
}
</script>
<style  lang="less" scoped>
.myinsuretwo{
    width: 100%;
    min-height: 100%;
    overflow: hidden;
    background-color: #FAF9F7;
     font-family: -apple-system, BlinkMacSystemFont,"Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",sans-serif;

}
.myinsuretwo_center{
    /* width: 90%; */
    overflow: hidden;
    margin: 0 auto;
    margin-top: 49px;
    margin-bottom: 9px;
}
.title{
    width: 90%;
    height: 42px;
    background-color: #ffffff;
    margin-top: 10px;
    border-radius: 10px;
    position: fixed;
    top: 0;
    left: 5%;
}
.titlecontent{
    width: 100%;
    height: 100%;
    position: relative;
}
.titlec{
    width: 100%;
    height: 100%;
    display: flex;
}
.titlec p{
    /* text-align: center; */
    font-size: 14px;
    color: #234439;
    line-height: 42px;
}
.titlec p:nth-child(1){
    width: 90px;
    padding: 0 0 0 20px;
}
.titlec p:nth-child(2){
     width: 90px;
    padding: 0  30px;
    text-align: center;
}
.titlec p:nth-child(3){
    width: 102px;
    padding: 0 20px 0 0;
    text-align: right;
}
.titlec p img{
    width: 10px;
    height: 7px;
    padding: 0 2px;
    margin-left:12px;
    vertical-align: middle;
    
}
.titlec p .active{
    transform: rotate(180deg);
}
.slide{
    position: absolute;
    width: 100%;
    overflow: hidden;
    border-radius: 5px;
}
.slide p{
    width: 92%;
    height: 46px;
    line-height: 42px;
    background-color: #DFF4F5;
    font-size: 14px;
    padding: 0 13.5px;
}
.slide p:first-child{
    background-color: #46A087;
    color: #ffff;
    border-radius: 5px;
}
/* 车险 */
.listcontent{
    width: 100%;
    overflow: hidden;
    background-color: #FAF9F7;
    /* margin-bottom: -14px; */
}
.listitem{
    width: 336px;
    height: auto;
    margin: 0 auto;
    background-color: #ffff;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 18px;
}
.itemtitle{
    width: 100%;
    height: 39px;
}
.itemtitle_div1{
    width: 100%;
    height: 100%;
}
.itemtitle_div1>.title1{
    color: #D09800;
    padding: 0 0 0 20px;
    font-size: 16px;
    display: block;
    float: left;
    margin: 14px 0 0 0;
    font-weight: bolder;
}
.itemtitle_div1 .title{
    width: 70%;
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    
}
.itemtitle_div1 .mystate{
    float: right;
    width: 50px;
    height: 29px;

}
.stateactive1{
    background-image: url(../../assets/img/q1.png);
        background-repeat: no-repeat;
    background-size: 100%;
}
.stateactive2{
    background-image: url(../../assets/img/q2.png);
        background-repeat: no-repeat;
    background-size: 100%;
}
.stateactive3{
    background-image: url(../../assets/img/q3.png);
        background-repeat: no-repeat;
    background-size: 100%;
}
.itemtitle_div1 div .state1{
    font-size: 14px;
    color: #ffff;
    letter-spacing: 1px;
    padding: 0 12px;
    display: block;
    margin: 7px 0 0 0;
    width: 75px;
    text-align: center;
}
.listitemcontent{
    width: 100%;
    overflow: hidden;
    /* padding: 0 0 10px 0; */
    margin-top: 14px;
}
.lactive{
    background-image: url(../../assets/img/g1.png);
    background-repeat: no-repeat;
    background-size: 100%;
    box-shadow: 1px 5px 10px #eaeaea;
    /* box-shadow: 0px 10px 0px 0px #fff0,-10px 0px 10px 10px #eaeaea, 10px 0px 10px 10px #eaeaea, 0px 10px 1px 1px #eaeaea; */
    height: 167px;
}
.lactive1{
    background-image: url(../../assets/img/g2.png);
    background-repeat: no-repeat;
    background-size: 100%;
     box-shadow: 1px 5px 10px #eaeaea;
    height: 146px
}
.listitemcontent p{
    width: 100%; 
    font-size: 13px;
    overflow: hidden;
     height: auto;
     line-height: 26px;
    margin: 0 0;
}
.listitemcontent p span{
    font-size: 13px;
    color: #234439;
}
.listitemcontent p span:first-child{
    padding: 0 0 0 20px;
    display: block;
    width: 30%;
    display: block;
    float: left;
    color: #666;
}
.listitemcontent p span:last-child{
    padding: 0 20px 0 0;
    display: block;
    word-wrap: break-word;
    text-align: right;
    width: 176px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    float: right;
    color: #000;
}
/* 非车险 */
.listcontent2{
    width: 100%;
    overflow: hidden;
    background-color: #FAF9F7;
   
}
.listitem2{
    width: 100%;
    overflow: hidden;
    margin: 15px 0;
    background-color: #ffff;
}
.itemtitle2{
    width: 100%;
    height: 45px;
}
.itemtitle2 div{
    width: 100%;
    height: 100%;
    line-height: 45px;
}
.itemtitle2 div span{
    color: #C5A457;
    padding: 0 0 0 21px;
    font-size: 14px;
}
.itemtitle2 div div{
    float: right;
    margin-right: -2px;
    width: 75px;
    height: 45px;
    border-radius: 0 0 50px 75px;
    background-color: teal;
}
.itemtitle2 div div span{
    font-size: 14px;
    color: #ffff;
    letter-spacing: 1px;
}
.listitemcontent2{
    width: 100%;
    overflow: hidden;
    padding: 0 0 10px 0;
}
.listitemcontent2 p{
    width: 100%;
    margin: 10px 0;;
}
.listitemcontent2 p span{
    font-size: 14px;
    color: #234439;
}
.listitemcontent2 p span:first-child{
    padding: 0 0 0 20px;
}
.listitemcontent2 p span:last-child{
    padding: 0 20px 0 0;
    float: right;
}
.bgcolor1{
    background-color: teal;
}
.bgcolor2{
    background-color: tomato;
}
.bgcolor3{
    background-color: blue;
}
.myInsure_btn{
        width: 200px;
    height: 56px;
    background: rgba(0, 172, 110, 1);
    border-radius: 10px;
    text-align: center;
    vertical-align: middle;
    line-height: 56px;
    margin: 0 auto;
}
.myInsure_btn span{
    font-family: PingFang SC;
    color: #234439;
    font-size: 14px;
}
.null{
    width: 100%;
    height: 550px;
    display: flex;
    align-items: center;
    justify-content: center;
}
</style>